package com.eight.clienthome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eight.clienthome.dao.ZoneCourseDao;
import com.eight.clienthome.dao.ZoneDao;
import com.eight.clienthome.service.ZoneService;
import com.eight.common.pojo.TbZone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/6/2 11:09
 */
@Service
public class ZoneServiceImpl implements ZoneService {

    @Autowired
    private ZoneDao zoneDao;
    @Autowired
    private ZoneCourseDao zoneCourseDao;
    @Override
    public List<TbZone> findAll() {
        TbZone tbZone = new TbZone();
        QueryWrapper<TbZone> wrapper = new QueryWrapper<>();
        wrapper.eq("is_disable",0);


        List<TbZone> tbZones = zoneDao.selectList(wrapper);


        for (TbZone zone : tbZones) {
            zone.setZoneCourses(zoneCourseDao.findAll(zone.getId()));
        }

        return tbZones;
    }
}
